package com.letwal.cmcvnd.assetdetail.adapter

import androidx.fragment.app.*
import com.letwal.cmcvnd.assetdetail.AssetDetailAllFragment
import com.letwal.cmcvnd.assetdetail.AssetDetailFailedFragment
import com.letwal.cmcvnd.assetdetail.AssetDetailInFragment
import com.letwal.cmcvnd.assetdetail.AssetDetailOutFragment

class AssetFragmentAdapter(
    fm: FragmentManager,
    behavior: Int = BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT
) :
    FragmentStatePagerAdapter(fm, behavior) {

    override fun getCount(): Int {
        return 4
    }

    override fun getItem(position: Int): Fragment {
        return when (position) {
            0 -> {
                AssetDetailAllFragment()
            }
            1 -> {
                AssetDetailOutFragment()
            }
            2 -> {
                AssetDetailInFragment()
            }
            3 -> {
                AssetDetailFailedFragment()
            }
            else -> {
                AssetDetailAllFragment()
            }
        }
    }

    override fun getItemPosition(`object`: Any): Int {
        return POSITION_NONE
    }

    override fun getPageTitle(position: Int): CharSequence {
        return when (position) {
            0 -> "All"
            1 -> "Out"
            2 -> "In"
            3 -> "Failed"
            else -> "All"
        }
    }

}